[%
<wizard>
	<page>
		<title>Select data type</title>
		<description>Select data type for which to create a strongly typed collection</description>
		<variable name="datatype"/>
	</page>	
</wizard>
%]Imports System
Imports System.Collections

Public Class [%<variable type="standard" name="filenamebase"/>%]
    Inherits CollectionBase

    Default Public Property Item(index As Integer) As [%<variable type="custom" name="datatype"/>%]
        Get
            Return CType(List(index), [%<variable type="custom" name="datatype"/>%])
        End Get
        Set
            List(index) = value
        End Set
    End Property

    Public Function Add(value As [%<variable type="custom" name="datatype"/>%]) As Integer
        Return List.Add(value)
    End Function 'Add

    Public Function IndexOf(value As [%<variable type="custom" name="datatype"/>%]) As Integer
        Return List.IndexOf(value)
    End Function 'IndexOf

    Public Sub Insert(index As Integer, value As [%<variable type="custom" name="datatype"/>%])
        List.Insert(index, value)
    End Sub 'Insert

    Public Sub Remove(value As [%<variable type="custom" name="datatype"/>%])
        List.Remove(value)
    End Sub 'Remove

    Public Function Contains(value As [%<variable type="custom" name="datatype"/>%]) As Boolean
        ' If value is not of type [%<variable type="custom" name="datatype"/>%], this will return false.
        Return List.Contains(value)
    End Function 'Contains


   Protected Overrides Sub OnInsert(index As Integer, value As [Object])
      ' Insert additional code to be run only when inserting values.
   End Sub 'OnInsert


   Protected Overrides Sub OnRemove(index As Integer, value As [Object])
      ' Insert additional code to be run only when removing values.
   End Sub 'OnRemove


   Protected Overrides Sub OnSet(index As Integer, oldValue As [Object], newValue As [Object])
      ' Insert additional code to be run only when setting values.
   End Sub 'OnSet


   Protected Overrides Sub OnValidate(value As [Object])
	  ' This check is commented out since it doesn't work for all types
      'If Not value.GetType() Is Type.GetType("[%<variable type="custom" name="datatype"/>%]") Then
      '   Throw New ArgumentException("value must be of type [%<variable type="custom" name="datatype"/>%].", "value")
      'End If
   End Sub 'OnValidate


End Class '[%<variable type="custom" name="datatype"/>%]Collection
